{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 1. 加载必要的模块"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "from pandas.core.frame import DataFrame\n",
    "import pandas as pd  \n",
    "import numpy as np\n",
    "import seaborn as sns\n",
    "from scipy.fftpack import fft,ifft\n",
    "from tqdm import tqdm"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 2. 确保csv数据格式如图所示\n",
    "\n",
    "![csv文件格式](https://raw.githubusercontent.com/techyoung-edu/sleepmonitor/master/acc_csv_format.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 3. 加载csv数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>time</th>\n",
       "      <th>acc</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>19:41:35.193</td>\n",
       "      <td>0.961693</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>19:41:35.226</td>\n",
       "      <td>0.963778</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>19:41:35.226</td>\n",
       "      <td>0.966693</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>19:41:35.263</td>\n",
       "      <td>0.963984</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>19:41:35.300</td>\n",
       "      <td>0.962294</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           time       acc\n",
       "0  19:41:35.193  0.961693\n",
       "1  19:41:35.226  0.963778\n",
       "2  19:41:35.226  0.966693\n",
       "3  19:41:35.263  0.963984\n",
       "4  19:41:35.300  0.962294"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dataset = pd.read_csv(\"39Hz_Accelerometer.csv\",names = [\"time\",\"acc\"])\n",
    "dataset.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "scrolled": true
   },
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 4. 处理acc数据\n",
    "+ 使用numpy array来对acc_list进行处理\n",
    "+ 把加速度减去1.0,这是传感器静态时默认的加速度。\n",
    "+ 把加速度乘1000,从而使的加速度变成以mg为单位。\n",
    "+ 求出期望和标准差"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the acc dist mean:-35.95mg and std:2.13mg\n"
     ]
    }
   ],
   "source": [
    "acc_list = np.array(dataset[\"acc\"])\n",
    "acc_list = (acc_list - 1.0)*1000\n",
    "acc_mean = np.mean(acc_list)\n",
    "acc_std  = np.std(acc_list)\n",
    "acc_mean_str = \"{:.2f}\".format(acc_mean)\n",
    "acc_std_str = \"{:.2f}\".format(acc_std)\n",
    "print(\"the acc dist mean:%.2fmg and std:%.2fmg\" %(acc_mean,acc_std))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 5. 绘制图片帧集文件夹dir_frames-小提琴+直方图\n",
    "+ 首先要在本notebook所在目录创建一个文件夹:dir_frames\n",
    "![图片](https://github.com/techyoung-edu/sleepmonitor/blob/master/violin_dist_combine.png?raw=true)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n",
      "\n",
      "\n",
      "  0%|                                                                                          | 0/900 [00:00<?, ?it/s]\n",
      "\n",
      "\n",
      "  0%|                                                                                  | 1/900 [00:02<43:58,  2.94s/it]\n",
      "\n",
      "\n",
      "  0%|▏                                                                                 | 2/900 [00:06<45:33,  3.04s/it]\n",
      "\n",
      "\n",
      "  0%|▎                                                                                 | 3/900 [00:09<48:00,  3.21s/it]\n",
      "\n",
      "\n",
      "  0%|▎                                                                                 | 4/900 [00:13<47:57,  3.21s/it]\n",
      "\n",
      "\n",
      "  1%|▍                                                                                 | 5/900 [00:16<48:39,  3.26s/it]\n",
      "\n",
      "\n",
      "  1%|▌                                                                                 | 6/900 [00:19<49:08,  3.30s/it]\n",
      "\n",
      "\n",
      "  1%|▋                                                                                 | 7/900 [00:23<50:00,  3.36s/it]\n",
      "\n",
      "\n",
      "  1%|▋                                                                                 | 8/900 [00:26<50:31,  3.40s/it]\n",
      "\n",
      "\n",
      "  1%|▊                                                                                 | 9/900 [00:30<50:16,  3.39s/it]\n",
      "\n",
      "\n",
      "  1%|▉                                                                                | 10/900 [00:33<49:56,  3.37s/it]\n",
      "\n",
      "\n",
      "  1%|▉                                                                                | 11/900 [00:37<50:34,  3.41s/it]\n",
      "\n",
      "\n",
      "  1%|█                                                                                | 12/900 [00:40<51:54,  3.51s/it]\n",
      "\n",
      "\n",
      "  1%|█▏                                                                               | 13/900 [00:44<51:41,  3.50s/it]\n",
      "\n",
      "\n",
      "  2%|█▎                                                                               | 14/900 [00:47<52:01,  3.52s/it]\n",
      "\n",
      "\n",
      "  2%|█▎                                                                               | 15/900 [00:51<53:47,  3.65s/it]\n",
      "\n",
      "\n",
      "  2%|█▍                                                                               | 16/900 [00:55<55:43,  3.78s/it]\n",
      "\n",
      "\n",
      "  2%|█▌                                                                               | 17/900 [00:59<55:06,  3.74s/it]\n",
      "\n",
      "\n",
      "  2%|█▌                                                                               | 18/900 [01:03<54:56,  3.74s/it]\n",
      "\n",
      "\n",
      "  2%|█▋                                                                               | 19/900 [01:06<54:47,  3.73s/it]\n",
      "\n",
      "\n",
      "  2%|█▊                                                                               | 20/900 [01:10<54:58,  3.75s/it]\n",
      "\n",
      "\n",
      "  2%|█▉                                                                               | 21/900 [01:14<54:16,  3.70s/it]\n",
      "\n",
      "\n",
      "  2%|█▉                                                                               | 22/900 [01:18<54:43,  3.74s/it]\n",
      "\n",
      "\n",
      "  3%|██                                                                               | 23/900 [01:21<54:05,  3.70s/it]\n",
      "\n",
      "\n",
      "  3%|██▏                                                                              | 24/900 [01:25<55:52,  3.83s/it]\n",
      "\n",
      "\n",
      "  3%|██▎                                                                              | 25/900 [01:30<58:54,  4.04s/it]\n",
      "\n",
      "\n",
      "  3%|██▎                                                                              | 26/900 [01:34<59:20,  4.07s/it]\n",
      "\n",
      "\n",
      "  3%|██▎                                                                            | 27/900 [01:38<1:00:09,  4.13s/it]\n",
      "\n",
      "\n",
      "  3%|██▌                                                                              | 28/900 [01:42<59:54,  4.12s/it]\n",
      "\n",
      "\n",
      "  3%|██▌                                                                              | 29/900 [01:46<59:32,  4.10s/it]\n",
      "\n",
      "\n",
      "  3%|██▋                                                                              | 30/900 [01:51<59:50,  4.13s/it]\n",
      "\n",
      "\n",
      "  3%|██▋                                                                            | 31/900 [01:55<1:00:31,  4.18s/it]\n",
      "\n",
      "\n",
      "  4%|██▊                                                                            | 32/900 [01:59<1:00:07,  4.16s/it]\n",
      "\n",
      "\n",
      "  4%|██▉                                                                            | 33/900 [02:03<1:00:36,  4.19s/it]\n",
      "\n",
      "\n",
      "  4%|███                                                                              | 34/900 [02:07<59:23,  4.12s/it]\n",
      "\n",
      "\n",
      "  4%|███                                                                            | 35/900 [02:12<1:00:57,  4.23s/it]\n",
      "\n",
      "\n",
      "  4%|███▏                                                                             | 36/900 [02:16<59:41,  4.14s/it]\n",
      "\n",
      "\n",
      "  4%|███▏                                                                           | 37/900 [02:20<1:00:11,  4.18s/it]\n",
      "\n",
      "\n",
      "  4%|███▎                                                                           | 38/900 [02:24<1:00:13,  4.19s/it]"
     ]
    }
   ],
   "source": [
    "acc_min = -128\n",
    "acc_max = +127\n",
    "figure,axes = plt.subplots(2,1,figsize = (16,9),sharex = False)\n",
    "for k in  tqdm(range(1000,acc_list.size,10)):\n",
    "    axes[0].set_xlim(acc_min, acc_max)\n",
    "    axes[1].set_xlim(acc_min, acc_max)\n",
    "    acc_list_slice = acc_list[k-1000:k]\n",
    "    acc_mean = np.mean(acc_list_slice)\n",
    "    acc_std  = np.std(acc_list_slice)\n",
    "    acc_mean_str = \"{:.2f}\".format(acc_mean)\n",
    "    acc_std_str = \"{:.2f}\".format(acc_std)\n",
    "    plt.title(\"MPU9520 acc distribution still. mean=\"+acc_mean_str+\"mg std=\"+acc_std_str+\"mg\") \n",
    "    sns.distplot(acc_list_slice,kde=True,bins=np.arange(acc_min,acc_max,0.1),ax=axes[0])\n",
    "    sns.violinplot(x=acc_list_slice,ax=axes[1])\n",
    "    axes[0].axvline(x=acc_mean,color=\"green\",linewidth=1)\n",
    "    axes[0].axvline(x=acc_mean-acc_std,color=\"r\",linewidth=1)\n",
    "    axes[0].axvline(x=acc_mean+acc_std,color=\"r\",linewidth=1)\n",
    "    axes[1].axvline(x=acc_mean,color=\"green\",linewidth=1)\n",
    "    axes[1].axvline(x=acc_mean-acc_std,color=\"r\",linewidth=1)\n",
    "    axes[1].axvline(x=acc_mean+acc_std,color=\"r\",linewidth=1)\n",
    "    filename_pfx = str(1000000+k)\n",
    "    plt.savefig(\"dir_frames/\"+filename_pfx+'.png',dpi=100)\n",
    "    axes[0].cla()\n",
    "    axes[1].cla()\n",
    "    plt.cla()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 5. 绘制图片帧集文件夹dir_frames-小提琴solo"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n",
      "\n",
      "  0%|                                                                                          | 0/900 [00:00<?, ?it/s]\n",
      "\n",
      "  0%|                                                                                  | 1/900 [00:00<02:20,  6.42it/s]\n",
      "\n",
      "  0%|▏                                                                                 | 2/900 [00:00<02:42,  5.54it/s]\n",
      "\n",
      "  0%|▎                                                                                 | 3/900 [00:00<02:38,  5.67it/s]\n",
      "\n",
      "  0%|▎                                                                                 | 4/900 [00:00<02:40,  5.57it/s]\n",
      "\n",
      "  1%|▍                                                                                 | 5/900 [00:00<02:44,  5.45it/s]\n",
      "\n",
      "  1%|▌                                                                                 | 6/900 [00:01<02:40,  5.57it/s]\n",
      "\n",
      "  1%|▋                                                                                 | 7/900 [00:01<02:43,  5.45it/s]\n",
      "\n",
      "  1%|▋                                                                                 | 8/900 [00:01<02:45,  5.40it/s]\n",
      "\n",
      "  1%|▊                                                                                 | 9/900 [00:01<02:44,  5.41it/s]\n",
      "\n",
      "  1%|▉                                                                                | 10/900 [00:01<02:47,  5.30it/s]\n",
      "\n",
      "  1%|▉                                                                                | 11/900 [00:02<02:47,  5.31it/s]\n",
      "\n",
      "  1%|█                                                                                | 12/900 [00:02<02:39,  5.58it/s]\n",
      "\n",
      "  1%|█▏                                                                               | 13/900 [00:02<02:52,  5.15it/s]\n",
      "\n",
      "  2%|█▎                                                                               | 14/900 [00:02<02:46,  5.32it/s]\n",
      "\n",
      "  2%|█▎                                                                               | 15/900 [00:02<02:38,  5.58it/s]\n",
      "\n",
      "  2%|█▍                                                                               | 16/900 [00:02<02:41,  5.47it/s]\n",
      "\n",
      "  2%|█▌                                                                               | 17/900 [00:03<02:37,  5.61it/s]"
     ]
    },
    {
     "ename": "KeyboardInterrupt",
     "evalue": "",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mKeyboardInterrupt\u001b[0m                         Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-9-fd08cdeb8941>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m     17\u001b[0m     \u001b[0mplt\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msavefig\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"dir_frames/\"\u001b[0m\u001b[1;33m+\u001b[0m\u001b[0mfilename_pfx\u001b[0m\u001b[1;33m+\u001b[0m\u001b[1;34m'.png'\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mdpi\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m100\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     18\u001b[0m     \u001b[0maxes\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcla\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 19\u001b[1;33m     \u001b[0mplt\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcla\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;32m~\\Anaconda3\\lib\\site-packages\\matplotlib\\pyplot.py\u001b[0m in \u001b[0;36mcla\u001b[1;34m()\u001b[0m\n\u001b[0;32m   2508\u001b[0m \u001b[1;33m@\u001b[0m\u001b[0mdocstring\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcopy_dedent\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mAxes\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcla\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   2509\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mcla\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 2510\u001b[1;33m     \u001b[1;32mreturn\u001b[0m \u001b[0mgca\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcla\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   2511\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   2512\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m~\\Anaconda3\\lib\\site-packages\\matplotlib\\axes\\_base.py\u001b[0m in \u001b[0;36mcla\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m    978\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    979\u001b[0m         \u001b[1;32mfor\u001b[0m \u001b[0mname\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mspine\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mspines\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mitems\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 980\u001b[1;33m             \u001b[0mspine\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcla\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    981\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    982\u001b[0m         \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mignore_existing_data_limits\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;32mTrue\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m~\\Anaconda3\\lib\\site-packages\\matplotlib\\spines.py\u001b[0m in \u001b[0;36mcla\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m    178\u001b[0m         \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_position\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;32mNone\u001b[0m  \u001b[1;31m# clear position\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    179\u001b[0m         \u001b[1;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0maxis\u001b[0m \u001b[1;32mis\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 180\u001b[1;33m             \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0maxis\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcla\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    181\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    182\u001b[0m     \u001b[1;32mdef\u001b[0m \u001b[0mis_frame_like\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m~\\Anaconda3\\lib\\site-packages\\matplotlib\\axis.py\u001b[0m in \u001b[0;36mcla\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m    811\u001b[0m                              rcParams['axes.grid.which'] in ('both', 'minor'))\n\u001b[0;32m    812\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 813\u001b[1;33m         \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mreset_ticks\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    814\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    815\u001b[0m         \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mconverter\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m~\\Anaconda3\\lib\\site-packages\\matplotlib\\axis.py\u001b[0m in \u001b[0;36mreset_ticks\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m    834\u001b[0m             \u001b[1;32mpass\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    835\u001b[0m         \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 836\u001b[1;33m             \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mset_clip_path\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0maxes\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mpatch\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    837\u001b[0m         \u001b[1;32mexcept\u001b[0m \u001b[0mAttributeError\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    838\u001b[0m             \u001b[1;32mpass\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m~\\Anaconda3\\lib\\site-packages\\matplotlib\\axis.py\u001b[0m in \u001b[0;36mset_clip_path\u001b[1;34m(self, clippath, transform)\u001b[0m\n\u001b[0;32m    924\u001b[0m         \u001b[0martist\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mArtist\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mset_clip_path\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mclippath\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtransform\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    925\u001b[0m         \u001b[1;32mfor\u001b[0m \u001b[0mchild\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmajorTicks\u001b[0m \u001b[1;33m+\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mminorTicks\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 926\u001b[1;33m             \u001b[0mchild\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mset_clip_path\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mclippath\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtransform\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    927\u001b[0m         \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mstale\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;32mTrue\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    928\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m~\\Anaconda3\\lib\\site-packages\\matplotlib\\axis.py\u001b[0m in \u001b[0;36mset_clip_path\u001b[1;34m(self, clippath, transform)\u001b[0m\n\u001b[0;32m    228\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    229\u001b[0m     \u001b[1;32mdef\u001b[0m \u001b[0mset_clip_path\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mclippath\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtransform\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mNone\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 230\u001b[1;33m         \u001b[0martist\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mArtist\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mset_clip_path\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mclippath\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtransform\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    231\u001b[0m         \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mgridline\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mset_clip_path\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mclippath\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtransform\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    232\u001b[0m         \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mstale\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;32mTrue\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m~\\Anaconda3\\lib\\site-packages\\matplotlib\\artist.py\u001b[0m in \u001b[0;36mset_clip_path\u001b[1;34m(self, path, transform)\u001b[0m\n\u001b[0;32m    684\u001b[0m             \u001b[1;32mif\u001b[0m \u001b[0misinstance\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mpath\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mRectangle\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    685\u001b[0m                 self.clipbox = TransformedBbox(Bbox.unit(),\n\u001b[1;32m--> 686\u001b[1;33m                                                path.get_transform())\n\u001b[0m\u001b[0;32m    687\u001b[0m                 \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_clippath\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    688\u001b[0m                 \u001b[0msuccess\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;32mTrue\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m~\\Anaconda3\\lib\\site-packages\\matplotlib\\patches.py\u001b[0m in \u001b[0;36mget_transform\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m    194\u001b[0m         \u001b[0mto\u001b[0m \u001b[0mthe\u001b[0m \u001b[1;33m:\u001b[0m\u001b[1;32mclass\u001b[0m\u001b[1;33m:\u001b[0m\u001b[0;31m`\u001b[0m\u001b[0mPatch\u001b[0m\u001b[0;31m`\u001b[0m\u001b[1;33m.\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    195\u001b[0m         \"\"\"\n\u001b[1;32m--> 196\u001b[1;33m         \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_patch_transform\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m+\u001b[0m \u001b[0martist\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mArtist\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_transform\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    197\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    198\u001b[0m     \u001b[1;32mdef\u001b[0m \u001b[0mget_data_transform\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m~\\Anaconda3\\lib\\site-packages\\matplotlib\\patches.py\u001b[0m in \u001b[0;36mget_patch_transform\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m    707\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    708\u001b[0m     \u001b[1;32mdef\u001b[0m \u001b[0mget_patch_transform\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 709\u001b[1;33m         \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_update_patch_transform\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    710\u001b[0m         \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_rect_transform\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    711\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m~\\Anaconda3\\lib\\site-packages\\matplotlib\\patches.py\u001b[0m in \u001b[0;36m_update_patch_transform\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m    686\u001b[0m         \u001b[0mbbox\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mtransforms\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mBbox\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mfrom_extents\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mx0\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0my0\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mx1\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0my1\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    687\u001b[0m         \u001b[0mrot_trans\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mtransforms\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mAffine2D\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 688\u001b[1;33m         \u001b[0mrot_trans\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mrotate_deg_around\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mx0\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0my0\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mangle\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    689\u001b[0m         \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_rect_transform\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mtransforms\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mBboxTransformTo\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mbbox\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    690\u001b[0m         \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_rect_transform\u001b[0m \u001b[1;33m+=\u001b[0m \u001b[0mrot_trans\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m~\\Anaconda3\\lib\\site-packages\\matplotlib\\transforms.py\u001b[0m in \u001b[0;36mrotate_deg_around\u001b[1;34m(self, x, y, degrees)\u001b[0m\n\u001b[0;32m   2009\u001b[0m         \u001b[1;31m# Cast to float to avoid wraparound issues with uint8's\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   2010\u001b[0m         \u001b[0mx\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0my\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mfloat\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mfloat\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0my\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 2011\u001b[1;33m         \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mtranslate\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m-\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m-\u001b[0m\u001b[0my\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mrotate_deg\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdegrees\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mtranslate\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0my\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   2012\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   2013\u001b[0m     \u001b[1;32mdef\u001b[0m \u001b[0mtranslate\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtx\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mty\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m~\\Anaconda3\\lib\\site-packages\\matplotlib\\transforms.py\u001b[0m in \u001b[0;36mtranslate\u001b[1;34m(self, tx, ty)\u001b[0m\n\u001b[0;32m   2021\u001b[0m         translate_mtx = np.array(\n\u001b[0;32m   2022\u001b[0m             [[1.0, 0.0, tx], [0.0, 1.0, ty], [0.0, 0.0, 1.0]], float)\n\u001b[1;32m-> 2023\u001b[1;33m         \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_mtx\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdot\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtranslate_mtx\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_mtx\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   2024\u001b[0m         \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0minvalidate\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   2025\u001b[0m         \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mKeyboardInterrupt\u001b[0m: "
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAA6oAAAIMCAYAAAD8TlFZAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAF0tJREFUeJzt3V+o5/dd5/HXuxmjUGsLzixIZjQBp1tnixD3ELr0wkq7yyQXMzddyUDRSujcbJRdixBRqsQrW5aCEP/MrqVasDH2QgcZyYVGFDElp3Q3mJTAEN3mECFjzeamtDG77704Z8vh5GTO90x+58ybcx4PGPh9v7/P+Z33xYfDec73+/ud6u4AAADAFO+43QMAAADAdkIVAACAUYQqAAAAowhVAAAARhGqAAAAjCJUAQAAGGXPUK2qz1XVK1X1d2/xfFXVb1TV9ap6tqp+bPVjAgAAcFwsuaL6+STnb/L8/UnObv27nOS33v5YAAAAHFd7hmp3/1WSf77JkotJfr83PZ3kPVX1A6saEAAAgONlF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/yeJKLO9ZcTPJ7W4+/lOTDVVUHPBfsx577uLuf6u5vbh0+nc2/NwzTLPmZnCS/ls3/bPnWYQ4HCy3Zx59I8lh3v5ok3f3KIc8ISyzZy53k+7YevzvJy4c4HyzS3X+Vzb/88lYuJvn93vR0kvdU1Q/s9boHHap3JXlp2/HG1rld13T3G0leS/L9BzwX7MeSfbzdQ0n+7EAngluz516uqnuTnOnuPz3MwWAflvxMfm+S91bV31TV01V1s//ph9tlyV7+1SQfq6qNbP4Fjp89nNFgpfb7u3SShX+e5m3Y7crozo8ZXrIGbqfFe7SqPpZkLcmPH+hEcGtuuper6h3ZfAvGxw9rILgFS34mn8jmLWYfyuYdLn9dVe/v7v99wLPBfizZy5eSfL67/2tV/bskX9jay//34MeDlbml3jvoK6obSc5sOz6dN9+y8J01VXUim7c13OzSMRy2Jfs4VfWRJL+U5EJ3f/uQZoP92GsvvyvJ+5P8ZVX9Q5IPJLnqA5UYZunvFn/S3f/S3X+f5IVshitMsmQvP5TkiSTp7r9N8j1JTh7KdLA6i36X3umgQ/WZJGer6p6qujObbwK/umPN1SQ/vfX4o0n+ov1xV2bZcx9v3S75O9mMVO+FYqqb7uXufq27T3b33d19dzbfb32hu9dvz7iwqyW/W/xxkp9Ikqo6mc1bgV881Clhb0v28teTfDhJqupHshmqNw51Snj7rib5qa1P//1Akte6+x/3+qIDvfW3u9+oqoeTPJnkjiSf6+7nqurRJOvdfTXJ72bzNobr2byS+uBBzgT7tXAffybJ9yb5o63PAvt6d1+4bUPDLhbuZRht4T5+Msl/qKrnk/yfJL/Q3d+4fVPDmy3cy59M8t+q6r9k81bJj7ugwzRV9cVsvtXi5Nb7qX8lyXclSXf/djbfX/1AkutJvpnkZxa9rr0OAADAJAd96y8AAADsi1AFAABgFKEKAADAKEIVAACAUYQqAAAAowhVAAAARhGqAAAAjCJUAQAAGOX/Ad1+wCfBxFdUAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 1152x648 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "acc_min = -128\n",
    "acc_max = +127\n",
    "figure,axes = plt.subplots(figsize = (16,9),sharex = False)\n",
    "for k in  tqdm(range(1000,acc_list.size,10)):\n",
    "    axes.set_xlim(acc_min, acc_max)\n",
    "    acc_list_slice = acc_list[k-1000:k]\n",
    "    acc_mean = np.mean(acc_list_slice)\n",
    "    acc_std  = np.std(acc_list_slice)\n",
    "    acc_mean_str = \"{:.2f}\".format(acc_mean)\n",
    "    acc_std_str = \"{:.2f}\".format(acc_std)\n",
    "    plt.title(\"MPU9520 acc distribution still. mean=\"+acc_mean_str+\"mg std=\"+acc_std_str+\"mg\") \n",
    "    sns.violinplot(x=acc_list_slice)\n",
    "    axes.axvline(x=acc_mean,color=\"green\",linewidth=0.2)\n",
    "    axes.axvline(x=acc_mean-acc_std,color=\"r\",linewidth=0.2)\n",
    "    axes.axvline(x=acc_mean+acc_std,color=\"r\",linewidth=0.2)\n",
    "    filename_pfx = str(1000000+k)\n",
    "    plt.savefig(\"dir_frames/\"+filename_pfx+'.png',dpi=100)\n",
    "    axes.cla()\n",
    "    plt.cla()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
